# Contributor: Leo <thinkabit.ukim@gmail.com>
# Maintainer:
pkgname=b3sum
pkgver=1.3.1
pkgrel=1
pkgdesc="Command line implementation of the BLAKE3 hash function"
url="https://blake3.io"
arch="all !s390x !riscv64"
license="CC0-1.0 OR Apache-2.0"
makedepends="cargo"
source="b3sum-$pkgver.tar.gz::https://crates.io/api/v1/crates/b3sum/$pkgver/download"

case "$CARCH" in
armhf)
	# hang forever, probably due to non-native hardware
	options="$options !check"
	;;
aarch64|armv7)
	_features="neon"
	;;
esac

export CARGO_PROFILE_RELEASE_LTO="true"
export CARGO_PROFILE_RELEASE_PANIC="abort"
export CARGO_PROFILE_RELEASE_CODEGEN_UNITS=1
export CARGO_PROFILE_RELEASE_OPT_LEVEL="s"

prepare() {
	default_prepare

	cargo fetch --locked
}

build() {
	cargo build --release --frozen ${_features:+--features $_features}
}

check() {
	cargo test --frozen ${_features:+--features $_features}
}

package() {
	install -Dm755 target/release/b3sum -t "$pkgdir"/usr/bin
}

sha512sums="
2af1731e672c07c0250d248bc626388b42267d63ca1c100d4ba6b1e58492c52eb05ee46b3e7da07cb0d5d4d4e567339e09e3d5199776ad32acc14b25bd594223  b3sum-1.3.1.tar.gz
"
